const uploadFilePromise = (url) => {
  uni.showLoading({
    title: '上传中',
  })
  return new Promise((resolve, reject) => {
    uni.uploadFile({
      url: '', // 仅为示例，非真实的接口地址
      filePath: url,
      name: 'file',
      formData: {
        user: 'test'
      },
      header: {
        'content-type': 'application/json',
        'X-Access-Token': uni.getStorageSync("token") || ''
      },
      success: (res) => {
        uni.hideLoading()
        resolve(JSON.parse(res.data))
        console.log(JSON.parse(res.data))

      },
      fail: (err) => {
        uni.hideLoading()
        uni.showModal({
          title: '',
          content: '系统忙，请重试！',
          showCancel: false,
        })
      }

    })
  })
}


export default uploadFilePromise
